home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 26 (Anniversary Edition)
/
Volume 26 [Anniversary Edition] - JOGO DISK .iso
/
Puzzle
/
allout.swf
/
scripts
/
frame_3
/
DoAction.as
Wrap
Text File
|
2006-05-29
|
9KB
|
289 lines
function TurnOn()
{
y = 1;
while(5 >= y)
{
x = 1;
while(5 >= x)
{
this["h" + x + y].gotoAndStop("oncomplete");
x++;
}
y++;
}
}
function Click(x, y)
{
holestatinc = 0;
xvals = new Array(-1,1,0,0);
yvals = new Array(0,0,-1,1);
moves++;
j = 0;
while(j < 4)
{
nx = x + xvals[j];
ny = y + yvals[j];
mc = "h" + nx + ny;
if(this[mc]._x)
{
this[mc].Swap();
}
j++;
}
if(!resetbutton.reset)
{
resetbutton.gotoAndStop(2);
}
if(PuzzleSolved())
{
if(0 < solver.count)
{
stop();
}
else
{
gotoAndPlay(137);
}
}
}
function ReadPuzzle(wp)
{
var puzzlines = new Array();
puzzlines = puzzles[wp].split("|");
j = 0;
while(j < 5)
{
puzzarray[j] = new Array();
puzzarray[j] = puzzlines[j].split(",");
j++;
}
}
function PuzzleSolved()
{
y = 0;
while(4 >= y)
{
x = 0;
while(4 >= x)
{
if(puzzarray[y][x] == 1)
{
return 0;
}
x++;
}
y++;
}
solved = true;
return 1;
}
function ShowPuzzle()
{
solver.stop();
solved = false;
moves = 0;
holestatinc = 1;
holestats = 0;
var x;
var y;
var knob;
y = 0;
while(y < 5)
{
x = 0;
while(x < 5)
{
knob = "h" + (x + 1) + (y + 1);
if(puzzarray[y][x] == 1 && this[knob].status == 0)
{
this[knob].gotoAndPlay("on");
holestats++;
}
if(puzzarray[y][x] == 0 && this[knob].status == 1)
{
this[knob].gotoAndPlay("off");
holestats++;
}
if(this[knob].solution == 1)
{
this[knob].base.gotoAndPlay("solutionoff");
}
x++;
}
y++;
}
timer.startTime = getTimer();
activebuttons = true;
resetbutton.gotoAndStop(1);
solvebutton.gotoAndStop(1);
randombutton.gotoAndStop(1);
_parent.activebuttons = true;
}
function Reset()
{
y = 1;
while(5 >= y)
{
x = 1;
while(5 >= x)
{
this["h" + x + y].base.gotoAndStop(1);
x++;
}
y++;
}
}
function SolvePuzzle()
{
var hint = new Array();
hint[0] = new Array(0,1,1,1,0,0,0,1,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0);
hint[1] = new Array(1,1,0,1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0);
hint[2] = new Array(1,0,1,1,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,1,0,1,0);
hint[3] = new Array(1,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1);
hint[4] = new Array(0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,0,0,1,0,1,1,1,0);
hint[5] = new Array(0,0,1,0,1,0,1,1,0,1,0,0,1,0,0,0,0,0,1,1,0,0,0);
hint[6] = new Array(0,1,0,1,0,1,1,0,1,1,0,0,0,1,0,1,1,1,0,0,0,1,0);
hint[7] = new Array(1,0,1,0,0,1,0,1,1,0,0,0,0,0,1,1,0,1,0,1,1,0,1);
hint[8] = new Array(0,0,1,0,0,0,1,1,1,0,1,0,0,1,1,1,0,0,1,0,0,1,1);
hint[9] = new Array(1,0,0,0,0,1,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,1);
hint[10] = new Array(0,0,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,1,0,0,1,0);
hint[11] = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1);
hint[12] = new Array(0,1,1,0,1,1,0,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,0);
hint[13] = new Array(1,1,1,0,0,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,0);
hint[14] = new Array(1,1,0,0,1,0,0,1,1,1,1,0,0,1,1,1,1,0,1,0,1,0,0);
hint[15] = new Array(0,0,1,0,0,0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,1);
hint[16] = new Array(0,0,1,1,0,0,1,0,0,1,1,1,0,0,1,0,1,1,1,0,0,0,1);
hint[17] = new Array(0,0,1,0,1,0,1,1,0,1,1,0,1,0,0,1,1,0,1,1,1,0,0);
hint[18] = new Array(0,1,1,0,0,1,0,0,1,0,1,0,0,1,1,0,1,1,1,0,0,0,1);
hint[19] = new Array(1,0,1,0,1,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,1,0,1);
hint[20] = new Array(0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,0,1,0,1,1,1,0);
hint[21] = new Array(0,0,1,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,1,1,1);
hint[22] = new Array(0,0,0,1,0,0,0,1,1,1,0,1,0,0,0,1,1,0,1,1,0,1,0);
goal = new Array();
j = 0;
while(j < 5)
{
goal[j] = new Array(0,0,0,0,0);
j++;
}
var current_state = new Array();
var hint_vector = new Array();
i = 0;
while(i < 23)
{
hint_vector[i] = 0;
if(puzzarray[i % 5][int(i / 5)] == 0)
{
current_state[i] = 0;
}
else
{
current_state[i] = 1;
}
i++;
}
i = 0;
while(i < 23)
{
j = 0;
while(j < 23)
{
hint_vector[i] = (hint_vector[i] + current_state[j] * hint[i][j]) % 2;
j++;
}
i++;
}
i = 0;
while(i < 23)
{
goal[i % 5][int(i / 5)] = hint_vector[i];
i++;
}
Reset();
}
function ShowSolution()
{
y = 0;
while(y < 5)
{
x = 0;
while(x < 5)
{
if(goal[y][x] == 1)
{
this["h" + (x + 1) + (y + 1)].base.gotoAndPlay("solutionon");
}
else
{
this["h" + (x + 1) + (y + 1)].base.gotoAndStop(1);
}
x++;
}
y++;
}
}
activebuttons = false;
puzzarray = new Array();
puzzles = new Array();
puzzles[1] = "1,1,0,1,1|1,0,1,0,1|0,1,1,1,0|1,0,1,0,1|1,1,0,1,1";
puzzles[2] = "0,1,0,1,0|1,1,0,1,1|0,1,0,1,0|1,0,1,0,1|1,0,1,0,1";
puzzles[3] = "1,0,0,0,1|1,1,0,1,1|0,0,1,0,0|1,0,1,0,0|1,0,1,1,0";
puzzles[4] = "1,1,0,1,1|0,0,0,0,0|1,1,0,1,1|0,0,0,0,1|1,1,0,0,0";
puzzles[5] = "1,1,1,1,1|1,1,1,1,1|1,1,1,1,1|1,1,1,1,1|1,1,1,1,1";
puzzles[6] = "0,1,1,1,0|1,0,0,0,1|1,0,1,0,1|1,0,0,0,1|0,1,1,1,0";
puzzles[6] = "0,0,0,1,1|0,0,0,1,1|0,0,0,0,0|1,1,0,0,0|1,1,0,0,0";
puzzles[7] = "0,0,0,0,0|0,1,1,1,0|1,1,1,1,1|0,1,1,1,0|0,0,0,0,0";
puzzles[8] = "0,0,0,0,0|0,1,1,1,0|0,1,1,1,0|0,1,1,1,0|0,0,0,0,0";
puzzles[9] = "1,1,0,1,1|1,1,0,1,1|0,0,0,0,0|1,1,0,1,1|1,1,0,1,1";
puzzles[10] = "1,1,1,1,1|0,1,1,1,0|0,0,1,0,0|0,1,1,1,0|1,1,1,1,1";
puzzles[11] = "1,1,1,1,1|1,0,0,0,1|1,0,0,0,1|1,0,0,0,1|1,1,1,1,1";
puzzles[12] = "0,0,1,1,1|0,0,0,1,1|1,0,0,0,1|1,1,0,0,0|1,1,1,0,0";
puzzles[13] = "1,0,0,0,1|0,1,0,1,0|0,0,1,0,0|0,1,0,1,0|1,0,0,0,1";
puzzles[14] = "1,1,1,1,1|1,0,1,0,1|1,1,1,1,1|1,0,1,0,1|1,1,1,1,1";
puzzles[15] = "1,0,0,0,0|1,1,1,1,0|1,1,1,1,0|1,1,1,1,0|1,1,1,1,1";
puzzles[16] = "1,1,1,1,1|1,1,1,1,1|1,1,0,1,1|1,1,1,1,1|1,1,1,1,1";
puzzles[17] = "1,0,1,0,1|0,1,0,1,0|0,0,1,0,0|0,1,0,1,0|1,0,1,0,1";
puzzles[18] = "1,1,1,0,1|1,1,1,0,1|0,0,0,0,0|1,0,1,1,1|1,0,1,1,1";
puzzles[19] = "1,1,0,1,1|1,1,0,1,1|1,1,0,1,1|1,1,0,1,1|1,1,0,1,1";
puzzles[20] = "1,1,1,1,1|1,0,0,0,1|1,1,0,1,1|1,1,0,1,1|1,1,1,1,1";
puzzles[21] = "1,1,1,1,1|1,1,1,1,1|0,0,0,1,1|0,0,0,1,1|0,0,0,1,1";
puzzles[22] = "1,1,1,0,1|1,1,1,0,0|1,1,1,0,0|1,1,1,0,0|1,1,1,0,1";
puzzles[23] = "1,1,1,1,1|0,0,1,0,0|0,0,1,0,0|0,0,1,0,0|1,1,1,1,1";
puzzles[24] = "0,0,0,0,0|0,1,1,0,0|0,1,1,1,0|0,0,1,1,0|0,0,0,0,0";
puzzles[25] = "0,0,0,1,1|0,0,1,1,1|0,0,1,0,0|1,1,1,0,0|1,1,0,0,0";
puzzles[26] = "0,0,0,1,1|1,1,0,1,1|1,1,0,0,0|1,1,0,0,0|1,1,0,1,1";
puzzles[27] = "1,0,0,0,1|0,1,1,1,0|0,1,1,1,0|0,1,1,1,0|1,0,0,0,1";
puzzles[28] = "1,0,1,0,1|0,1,0,1,0|1,0,1,0,1|0,1,0,1,0|1,0,1,0,1";
puzzles[29] = "0,0,1,0,0|1,0,0,1,0|0,1,1,1,1|1,0,0,0,0|1,1,0,1,0";
puzzles[30] = "0,0,0,0,1|0,0,0,1,1|0,0,1,0,1|0,1,0,0,1|1,1,1,1,1";
puzzles[31] = "1,1,0,1,1|0,1,0,1,0|1,1,1,1,1|1,1,0,1,1|1,0,0,0,1";
puzzles[32] = "0,1,1,0,0|0,1,1,0,1|0,1,0,0,1|1,1,0,0,0|1,1,1,1,0";
puzzles[33] = "0,0,0,0,1|1,1,1,0,0|1,0,1,1,1|1,1,1,1,0|1,0,0,1,0";
puzzles[34] = "1,0,1,1,1|0,0,1,0,1|0,0,0,0,0|1,1,1,1,0|1,1,0,1,0";
puzzles[35] = "1,1,0,1,1|0,1,0,1,1|0,0,0,1,0|1,1,0,0,0|1,1,1,1,0";
puzzles[36] = "1,1,1,1,1|0,0,0,1,0|0,1,0,1,1|1,1,1,0,1|1,0,1,0,0";
puzzles[37] = "0,0,0,1,1|1,0,1,1,0|0,0,1,0,0|0,1,1,1,1|1,0,0,1,0";
puzzles[38] = "0,0,0,0,1|0,0,1,1,1|1,1,0,0,1|1,1,1,0,0|0,0,1,0,0";
puzzles[39] = "0,0,1,1,1|1,0,1,1,1|1,1,1,0,0|0,0,1,0,0|1,1,0,1,1";
puzzles[40] = "0,1,1,1,1|0,0,1,1,1|0,0,1,1,1|1,1,1,1,0|0,0,0,1,0";
puzzles[41] = "1,1,1,1,1|1,0,0,0,0|0,1,0,0,1|0,0,0,1,1|1,1,1,1,1";
puzzles[42] = "1,1,1,1,1|1,0,0,0,0|0,0,1,0,0|0,1,1,1,0|0,1,0,0,1";
puzzles[43] = "0,0,0,0,0|0,0,0,1,0|1,1,0,1,1|0,1,1,0,0|1,1,1,1,1";
puzzles[44] = "0,0,0,1,1|0,1,1,0,0|0,1,0,0,0|1,1,1,1,0|1,1,1,1,0";
puzzles[45] = "0,0,0,1,0|1,1,1,1,1|0,0,0,0,0|0,0,1,0,0|1,1,1,1,0";
puzzles[46] = "0,1,0,1,0|0,0,0,1,0|0,1,0,1,0|0,0,1,0,0|0,1,1,1,0";
puzzles[47] = "1,0,0,1,0|0,0,0,0,1|0,1,0,0,0|0,0,0,0,0|1,0,1,0,0";
puzzles[48] = "1,1,0,0,1|0,1,0,0,1|0,1,1,1,1|0,1,0,1,0|1,1,1,1,1";
puzzles[49] = "1,1,1,1,1|0,0,1,0,0|0,1,1,0,0|0,0,1,1,0|1,1,1,0,1";
puzzles[50] = "1,0,1,0,1|1,0,1,0,0|0,0,0,1,1|0,1,0,1,0|1,0,0,1,0";
puzzles[51] = "0,1,0,1,0|1,0,0,1,0|0,1,1,1,1|1,0,1,0,0|0,1,1,0,0";
puzzles[52] = "1,1,1,1,1|1,1,0,0,0|0,0,0,1,1|0,1,1,1,0|0,0,1,0,0";
puzzsize = puzzles.length - 1;
chooser.levelnum = 1;
popSound = new Sound();
popSound.attachSound("pop");
winSound = new Sound();
winSound.attachSound("winsound");
lewbeep = new Sound();
lewbeep.attachSound("lewbeep");